#if !defined(AFX_CLIENTSOCKET_H__F784D707_7758_4379_B4D8_2B7181C5081C__INCLUDED_)
#define AFX_CLIENTSOCKET_H__F784D707_7758_4379_B4D8_2B7181C5081C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ClientSocket.h : header file
//
#define MAX_BUFFER_LEN 16
#define SND_STX	0x7e
#define SND_ETX	0x7c
#define SND_LEN	8
#define RCV_STX	0x7d
#define RCV_ETX	0x7c
#define RCV_LEN	9
#define RCV_DATA_LEN 7
class CNetworkManager;

/////////////////////////////////////////////////////////////////////////////
// CClientSocket command target

class CClientSocket : public CAsyncSocket
{
// Attributes
public:

// Operations
public:
	CClientSocket(CNetworkManager* pNetMgr);
	virtual ~CClientSocket();

// Overrides
public:
	int UDPSendTo(const void* lpBuf, int nBufLen, UINT nHostPort, LPCTSTR lpszHostAddress);
	int m_nPort;
	CString m_strIP;
	bool validPackage(unsigned char * pPackage, int nPackageLen,bool bcheckSUM);
	char m_ReaderBuffer[MAX_BUFFER_LEN];//refactory 1024 ==> MAX_BUFFER
	int  m_nTotalBytes;
	void CloseSocket();
	char m_strSendBuffer[MAX_BUFFER_LEN];
	unsigned char m_strPackageData[RCV_DATA_LEN];
	CList<char*,char*> m_listSendBuffer;
	CList<char*,char*> m_listReveiveItems;
	int SendData(char * pbuff,int ilen);
	//CArray m_ArrDataToSend;
	CString m_strSocketMode;  //TCP or UDP
	//CUPSMonitorDoc* m_pDoc;
	CNetworkManager * m_pNetMgr;
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CClientSocket)
	public:
	virtual void OnReceive(int nErrorCode);
	virtual void OnSend(int nErrorCode);
	virtual void OnConnect(int nErrorCode);
	virtual void OnClose(int nErrorCode);
	//}}AFX_VIRTUAL

	// Generated message map functions
	//{{AFX_MSG(CClientSocket)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG

// Implementation
protected:
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CLIENTSOCKET_H__F784D707_7758_4379_B4D8_2B7181C5081C__INCLUDED_)
